officeSSIDs = {"Me2Zen_Internal"}
homeSSIDs = {"Xiaomi_DCE2","HUAWEI-400RP8"}
hotSSIDs = {"HONOR Play4T Pro"}

title = "Wifi网络变更"

function isInSSIDs(ssid,t)
    for _,v in ipairs(t) do
        if ssid == v then
            return true
        end
    end
    return false
end

function ssidChangedCallback()
    ssid = hs.wifi.currentNetwork()
    
    -- 公司网络
    if isInSSIDs(ssid,officeSSIDs) then
        hs.notify.show(title, "公司网络", ""..ssid)
        hs.audiodevice.defaultOutputDevice():setVolume(0)
    end
    -- 家庭网络
    if isInSSIDs(ssid,homeSSIDs) then 
        hs.notify.show(title, "家庭网络", ""..ssid)
        hs.audiodevice.defaultOutputDevice():setVolume(50)
    end
    -- 热点
    if isInSSIDs(ssid,hotSSIDs) then
        hs.notify.show(title, "热点", ""..ssid)
        hs.audiodevice.defaultOutputDevice():setVolume(30)
    end

    -- 挂载共享目录
    -- hs.timer.delayed.new(3, function() 
    --     if not hs.fs.urlFromPath("/Volumes/游戏化课件") then
    --         hs.notify.show(title, "挂载共享目录","游戏化课件")
    --         hs.execute("open ~/Desktop/ConnectNFS.app")
    --     end
    -- end):start()
    -- hs.messages.iMessage("zhaoheng@rouchi.com", "Hey! I'm at Baristartisan's, come join me!")
    -- hs.messages.SMS("+8618410077586", "Hey, you don't have an iPhone, but you should still come for a coffee")
    -- hs.notify.show(title, "热点", "" .. ssid)
    -- hs.audiodevice.defaultOutputDevice():setVolume(30)
end

wifiWatcher = hs.wifi.watcher.new(ssidChangedCallback)
wifiWatcher:start()